package it.traveldream.entities;



import it.traveldream.dto.HotelDTO;
import it.traveldream.dto.HotelDTO.HotelRoomType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyColumn;
import javax.persistence.MapKeyEnumerated;
import javax.persistence.OneToMany;

/**
 * Entity implementation class for Entity: BookedHotel
 *
 */
@Entity
@DiscriminatorValue(ProductType.HOTEL)
public class BookedHotel extends BookedProduct {

	@ElementCollection
	@CollectionTable(name="BookedRooms", joinColumns= @JoinColumn(name="HOTELID"))
	@MapKeyColumn(name = "ROOMTYPE", length = 50, nullable = false)
	@MapKeyEnumerated(EnumType.STRING)
	@Column(name = "QUANTITY", length = 100)
	private Map<HotelRoomType, Integer> bookedRooms = new HashMap<>();
	
	@OneToMany(mappedBy = "hotel", cascade = CascadeType.ALL)
	private List<Reservation> reservations;
	
	private static final long serialVersionUID = 1L;

	public BookedHotel() {
		super();
	}

	public Map<HotelRoomType, Integer> getBookedrooms() {
		return this.bookedRooms;
	}

	public void setBookedRooms(Map<HotelRoomType, Integer> bookedRooms) {
		this.bookedRooms = bookedRooms;
	}

	public List<Reservation> getReservations() {
		return this.reservations;
	}

	public void setReservation(List<Reservation> reservations) {
		this.reservations = reservations;
	}

	@Override
	public HotelDTO toDTO() {
		return ((Hotel)this.getProduct()).toDTO();
	}

   
}
